package sctu.edu.java.year2016.team05.lizixin.day20160522.chapter4_3;

/**
 * Created by home on 2016/5/22.
 * 编写java程序，使用while循环语句计算1+1/2!+1/3!+1/4!+....1/20!之和。
 */
public class xunhuan {
    public static void main(String[] args) {
        double sum = 0, a = 1;
        int i = 1;
        while (i <= 20) {
            sum = sum + a;
            i = i + 1;
            a = a * (1.0 / i);
        }
        System.out.println(sum);
    }
}
